#include "ExtractStreamFilterData.h"
#include "StreamResTweetData.h"
#include <fstream>
#include <string>
#include <ctime>

ExtractStreamFilterData::ExtractStreamFilterData(void)
{
}

ExtractStreamFilterData::~ExtractStreamFilterData(void)
{
}

void ExtractStreamFilterData::doExtractData(std::istream &is, std::ostream &os)
{
	time_t t1, t2;
	t1 = time(0);
	t2 = time(0);
	while(is.good() && (t2 - t1) < 10){
		////is.get(); //remove the first {
		//JSONObject json;
		//json.setData(is);

		//os << dynamic_cast<JSONString *>(json.getData("id_str"))->getData() << ",\t";
		//os << dynamic_cast<JSONString *>(json.getData("created_at"))->getData() << ",\t";
		//os << dynamic_cast<JSONString *>(dynamic_cast<JSONObject *>(json.getData("user"))->getData("id_str"))->getData() << ",\t";
		//os << dynamic_cast<JSONString *>(json.getData("text"))->getData() << std::endl;

		StreamResTweetData res;
		res.setData(is);


		if(res.isTewwts()){
			os << res.getResTweetID() << "\t";
			os << res.getResTweetCreatedTime() << "\t";
			os << res.getResTweetFromUserID()  << "\t";
			os << res.getResTweetText()        << std::endl;


		}

		is.get();
		is.get();
		t2 = time(0);
	}
}